package com.coderman.infosys.auth.infrast.gatawayimpl;

import java.util.List;

import com.coderman.infosys.auth.infrast.cache.UserRoleGroupCache;
import com.coderman.infosys.plat.auth.common.page.PageBO;
import com.coderman.infosys.auth.domain.bo.role.RoleBO;
import com.coderman.infosys.auth.domain.bo.user.UserGroupBO;
import com.coderman.infosys.auth.domain.gataway.UserRoleQueryGataway;
import com.coderman.infosys.auth.domain.bo.role.RoleGroupBO;
import com.coderman.infosys.auth.infrast.dao.dataobject.RoleDO;
import com.coderman.infosys.auth.infrast.dao.mapper.RoleMapper;
import com.coderman.infosys.auth.infrast.dataconvert.RoleConvert;
import com.coderman.infosys.auth.infrast.dataconvert.UserGroupConvert;
import com.coderman.infosys.auth.infrast.dao.mapper.UserGroupMapper;
import com.coderman.infosys.auth.infrast.dao.mapper.RoleGroupMapper;
import com.coderman.infosys.auth.infrast.dao.dataobject.RoleGroupDO;
import com.coderman.infosys.auth.infrast.dataconvert.RoleGroupConvert;
import com.coderman.infosys.auth.infrast.dao.dataobject.UserGroupDO;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @Description:用户和角色相关查询接口实现类
 * @Author：
 * @CreateTime：2022-01-02 15:27:38
 * @version v1.0
 */
@Service
public class UserRoleQueryGatawayImpl  implements UserRoleQueryGataway{

    @Autowired
    private RoleGroupMapper roleGroupMapper;

    @Autowired
    private UserGroupMapper userGroupMapper;

    @Autowired
    private RoleMapper roleMapper;

    @Autowired
    private UserRoleGroupCache userRoleGroupCache;

    @Override
	public List<RoleBO> getRolePageList(PageBO pageBO){
        List<RoleDO> roleDOList = roleMapper.getPageList(pageBO);
        Integer totalCount = roleMapper.getTotalCount(pageBO);
        pageBO.setTotalRows(totalCount);
        return RoleConvert.INSTANCE.doList2boList(roleDOList);
    }

    @Override
	public List<UserGroupBO> getUserGroupPageList(PageBO pageBO){
        List<UserGroupDO> userGroupDOList = userGroupMapper.getUserGroupPageList(pageBO);
        int totalCount = userGroupMapper.getTotalCount(pageBO);
        pageBO.setTotalRows(totalCount);
        return UserGroupConvert.INSTANCE.doList2boList(userGroupDOList);
    }

    @Override
	public List<RoleGroupBO> getRoleGroupPageList(PageBO pageBO) {
        List<RoleGroupDO> roleGroupDOList = roleGroupMapper.getRoleGroupPageList(pageBO);
        return RoleGroupConvert.INSTANCE.doList2boList(roleGroupDOList);
    }

    @Override
	public List<RoleBO> searchRole(String search){
        List<RoleDO> roleDOList = roleMapper.search(search);
        return RoleConvert.INSTANCE.doList2boList(roleDOList);
    }

    @Override
	public List<RoleGroupBO> searchRoleGroup(String search){
        List<RoleGroupDO> roleGroupDOList = roleGroupMapper.search(search);
        return RoleGroupConvert.INSTANCE.doList2boList(roleGroupDOList);
    }

    @Override
    public List<UserGroupBO> searchUserGroup(String search) {
        List<UserGroupDO> userGroupDOList = userGroupMapper.search(search);
        return UserGroupConvert.INSTANCE.doList2boList(userGroupDOList);
    }

}